{% extends "nav.html" %}
{% block little %}日志信息{% endblock %}
{% block content %}
    <!-- Main Content -->
    <div class="container-fluid">
        <div class="side-body">
            <div class="page-title">
                <span class="title">光交日志</span>
                <div class="description">日志导入</div>
            </div>
            <div class="row">
                <div class="col-xs-12">
                    <div class="card">
                        <div class="card-header">
                            <div class="card-title">
                                <div class="title">{{ little }}日志导入方案</div>
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="row">
                                <div class="col-sm-1"><th  ><h4>光交：</h4></th></div>
                                <div class="col-sm-2">
                                    <th >
                                        <select class="form-control" id="caiji_san">
                                            {% for i in data %}
                                                <option name="{{ i.id }}">{{ i.prodect }}-{{ i.ip }}</option>
                                            {% endfor %}
                                        </select>
                                    </th>
                                </div>
                            </div>
                            <div>
                                <textarea class="form-control" id="textdata" rows="3"style="height:400px;"></textarea>
                            </div>
                            <button type="button" class="btn btn-primary" id="san_import">信息导入</button>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>

{% endblock %}
{% block js %}
    <div class="modal fade" tabindex="-1" role="dialog" id="san_update">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">更新光交信息</h4>
                </div>
                <div class="modal-body">
                    <p id="san_err">更新中,请等待&hellip;</p>
                    <div class="progress">
                        <div id="san_jindutiao" class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default st_close" data-dismiss="modal" id="ST_close">关闭</button>
                    {#                    <button type="button" class="btn btn-primary">Save changes</button>#}
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <script>
        $('#san_import').click(function () {
            $('#san_update').modal({backdrop: 'static', keyboard: false},'toggle')
            $("#ST_close").hide();
            var sanid = $("#caiji_san").find("option:selected").attr("name");
            $.ajax({
{#                url: "{% url "san_huitu_update" %}",#}
                url: "{% url "san_liuliang_im" %}",
                type: 'POST',
                data:{id:sanid,text:$("#textdata").val()},
                success: function(data){
                    var obj = JSON.parse(data);
                    if(obj.status){
                        $("#san_err").text("更新成功");
                        $("#ST_close").show();
                        $("#san_jindutiao").hide();
                    }else{
                        $("#san_err").text(obj.error);
                        $("san_jindutiao").hide();
                        $("#ST_close").show();
                    };
                }
            })
        });
    </script>
{% endblock %}